package top.jolyoulu.jlmqtt.entity.dto;

import lombok.Data;
import lombok.experimental.Accessors;
import top.jolyoulu.corecommon.utils.other.IdUtils;

import java.time.LocalDateTime;

/**
 * 心跳消息
 */
@Data
@Accessors(chain = true)
public class MqttHeartBeatMsgDTO extends MqttMsgContentDTO<MqttHeartBeatMsgDTO> {

    /**
     * 设备sn
     */
    private String deviceSn;

    /**
     * 当前设备锁定生态 0未锁定 1锁定
     */
    private Integer lockStatus;

    /**
     * 锁定/未锁定时长(秒)
     * -1 没有时间限制
     */
    private Integer timeOut;

    /**
     * 最后心跳时间
     */
    private LocalDateTime lastTime;

    public MqttHeartBeatMsgDTO() {
    }

    public MqttHeartBeatMsgDTO(String deviceSn) {
        this.deviceSn = deviceSn;
    }

    @Override
    public MqttMsgDTO<MqttHeartBeatMsgDTO> build() {
        return new MqttMsgDTO<MqttHeartBeatMsgDTO>(IdUtils.simpleUUID(), MqttMsgType.HEART_BEAT)
                .setContent(this);
    }
}
